package com.keming.service.Impl;

import com.keming.dao.UserDao;
import com.keming.pojo.User;
import com.keming.service.UserService;
import com.keming.util.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public User checkUser(String username, String password) {
        User user =new User();
        if (username!=null && password!=null){
            user = userDao.findByUsernameAndPassword(username);
            if (MD5Utils.code(password).equals(user.getPassword())){
                System.out.println("密码正确");
            }else {
                user=null;
                System.out.println("密码错误");
            }
        }else {
            user=null;
            System.out.println("账号密码为空");
        }
        return user;

    }
}

